/*
* Copyright (c) 2009 contentismissing.net, artifacts.de
*
* All rights reserved.
*
* Authors: Jens Lembke <j@contentismissing.net>;
*          Michael Markowski <m.markowski@artifacts.de>;
*
* All non-exclusive rights granted to Deutsche Telekom AG Laboratories
*
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
/**
* DragBehaviour - Moves the object to the cursor position 
* Uses caurina tweener for moving.  
*/
package net.contentismissing.tlabs.cocktailparty.behaviours
{
	import de.artifacts.multitouch.Cursor;
	import de.artifacts.multitouch.TouchEvent;
	import de.artifacts.multitouch.behaviours.ScaleBehaviour
	import net.contentismissing.tlabs.cocktailparty.Constants;
	import net.contentismissing.tlabs.cocktailparty.ui.Menu;
	import flash.events.Event;
	public class VolumeButtonScaleBehaviour extends ScaleBehaviour
	{
		public var menu : Menu;
		public function VolumeButtonScaleBehaviour(menu : Menu)
		{
			this.menu = menu;
		}

		override public function repositionedHandler(event : TouchEvent) : void
		{
			if (this.touchingCursors == null || this.touchingCursors.length < 2) return;
			var cursor1 : Cursor = this.touchingCursors[0];
			var cursor2 : Cursor = this.touchingCursors[1];
			var distance : Number = manhattanDistance(cursor1.position , cursor2.position);
			var scale : Number = distance / DISTANCE_SCALE_FACTOR - initialScale;
			touchable.wrappee.scaleX = Math.min(Math.max(minScale , scale) , maxScale);
			touchable.wrappee.scaleY = Math.min(Math.max(minScale , scale) , maxScale);
			menu.onVolumeScale();
		}
	}
}
